//package com.plian.system.service.zzd.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.DateUtil;
//import com.plian.Tools.StringPool;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.dto.zzd.ZZDIndicatorsQuery;
//import com.plian.system.dto.zzd.ZZDQuery;
//import com.plian.system.entity.fr.enterprise.Enterprise;
//import com.plian.system.entity.fr.indicators.GraphicOrgRelation;
//import com.plian.system.entity.im.*;
//import com.plian.system.entity.sys.Org;
//import com.plian.system.service.fr.enterprise.IEnterpriseService;
//import com.plian.system.service.fr.indicatorsvalue.IGraphicOrgRelationService;
//import com.plian.system.service.im.*;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.service.zzd.IZZDInvestmentAnnualService;
//import com.plian.system.vo.zzd.finance.IndicatorsUnitDetailVO;
//import com.plian.system.vo.zzd.investment.InvestmentAnnualVO;
//import com.plian.system.vo.zzd.investment.InvestmentFinishVO;
//import com.plian.system.vo.zzd.investment.ProjectNatureVO;
//import com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.exception.ExceptionUtils;
//import org.springframework.stereotype.Service;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @Description: TODO
// * @Author: Take-off
// * @Date: 2023/3/15 9:59 AM
// * @Param
// * @return
// * @Version: 1.0
// **/
//@Slf4j
//@Service
//@AllArgsConstructor
//public class ZZDInvestmentAnnualServiceImpl implements IZZDInvestmentAnnualService {
//
//    private IOrgService orgService;
//
//    private IEnterpriseService enterpriseService;
//
//    //项目信息
//    private IProjectInfoService projectInfoService;
//
//    //固定资产投资
//    private IFixedInvestmentPlanService fixedInvestmentPlanService;
//
//    //股权投资计划
//    private IStakeInvestmentPlanService stakeInvestmentPlanService;
//
//    //投资计划
//    private IBaseInvestmentPlanService baseInvestmentPlanService;
//
//    //投资计划执行
//    private IBaseInvestmentExecutionService baseInvestmentExecutionService;
//
//    //执行-有效投资
//    private IEffectiveInvestmentService effectiveInvestmentService;
//
//    //执行-股权/固定
//    private IExecutionProjectSituationService executionProjectSituationService;
//
//    //合并节点
//    private IGraphicOrgRelationService graphicOrgRelationService;
//
//    @Override
//    public InvestmentAnnualVO getInvestmentAnnual(ZZDQuery query){
//        InvestmentAnnualVO investmentAnnualVO = InvestmentAnnualVO.builder().yearPlanInvestment(BigDecimal.ZERO).yearCompleteInvestment(BigDecimal.ZERO).fixedAssetsInvestment(BigDecimal.ZERO)
//                .equityInvestment(BigDecimal.ZERO).effectiveInvestmentCompletionRate(BigDecimal.ZERO).keyProjectInvestmentCompletionRate(BigDecimal.ZERO).build();
//        //组织Id
//        List<String> orgIds = new ArrayList<>();
//        if (query.getOrgType() == 1){
//            //全大市
//            orgIds = orgService.getAllOrg().stream().map(Org::getId).collect(Collectors.toList());
//        }else {
//            //监管企业
//            orgIds = orgService.getGzwUnits(orgService.getDTFlag(query.getReportTime())).stream().map(Org::getId).collect(Collectors.toList());
//        }
//        //本年计划投资
//        String[] strList = query.getReportTime().split(StringPool.DASH);
//        String year = strList[0];
//        List<BaseInvestmentPlan> planList = baseInvestmentPlanService.list(new LambdaQueryWrapper<BaseInvestmentPlan>().eq(BaseInvestmentPlan::getFilingYear, year)
//                .in(BaseInvestmentPlan::getFilingUnitId, orgIds));
//
//        BigDecimal planInvestment = BigDecimal.ZERO;
//        if (CollectionUtil.isNotEmpty(planList)){
//            planInvestment = planList.stream().map(BaseInvestmentPlan::getPlannedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//
//            if (planInvestment.compareTo(BigDecimal.ZERO) <= 0) {
//                List<FixedInvestmentPlan> fixedInvestmentPlans = fixedInvestmentPlanService.list(new LambdaQueryWrapper<FixedInvestmentPlan>().in(FixedInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//                if (CollectionUtil.isNotEmpty(fixedInvestmentPlans)) {
//                    BigDecimal totalInvestment = fixedInvestmentPlans.stream().map(FixedInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//                List<StakeInvestmentPlan> stakeInvestmentPlans = stakeInvestmentPlanService.list(new LambdaQueryWrapper<StakeInvestmentPlan>().in(StakeInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//                if (CollectionUtil.isNotEmpty(stakeInvestmentPlans)) {
//                    BigDecimal totalInvestment = stakeInvestmentPlans.stream().map(StakeInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//            }
//            investmentAnnualVO.setYearPlanInvestment(planInvestment.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
//        }
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, query.getReportTime()).in(BaseInvestmentExecution::getFilingUnitId, orgIds));
//        if (CollectionUtil.isNotEmpty(executions)){
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)){
//                //已经完成投资
//                BigDecimal completeInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                investmentAnnualVO.setYearCompleteInvestment(completeInvestment.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
//                //固定资产投资
//                BigDecimal completeFixedInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteFixedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                investmentAnnualVO.setFixedAssetsInvestment(completeFixedInvestment.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
//                //股权投资
//                BigDecimal completeEquityInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteEquityInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                investmentAnnualVO.setEquityInvestment(completeEquityInvestment.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
//                //有效投资完成率
//                if (planInvestment.compareTo(BigDecimal.ZERO)>0){
//                    BigDecimal divide = completeInvestment.multiply(new BigDecimal("100")).divide(planInvestment, 2, RoundingMode.HALF_UP);
//                    investmentAnnualVO.setEffectiveInvestmentCompletionRate(divide);
//                }
//
//                //重点项目
//                List<ExecutionProjectSituation> projectSituations = executionProjectSituationService.list(new LambdaQueryWrapper<ExecutionProjectSituation>().in(ExecutionProjectSituation::getEffectiveInvestmentId,
//                        effectiveInvestments.stream().map(EffectiveInvestment::getId).collect(Collectors.toList())));
//                if (CollectionUtil.isNotEmpty(projectSituations)){
//                    List<ExecutionProjectSituation> mainProjects = projectSituations.stream().filter(m -> Optional.ofNullable(m.getIsMain()).isPresent() && m.getIsMain() == 2).collect(Collectors.toList());
//                    //全年计划和
//                    BigDecimal planTotalInvestment = mainProjects.stream().map(ExecutionProjectSituation::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    //至上月底完成
//                    BigDecimal lastCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getLastCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    //本月完成投资
//                    BigDecimal thisCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    if (planTotalInvestment.compareTo(BigDecimal.ZERO)>0){
//                        BigDecimal divide = (lastCompleteInvestment.add(thisCompleteInvestment)).multiply(new BigDecimal("100")).divide(planTotalInvestment, 2, RoundingMode.HALF_UP);
//                        investmentAnnualVO.setKeyProjectInvestmentCompletionRate(divide);
//                    }
//                }
//            }
//        }
//        return investmentAnnualVO;
//    }
//
//    @Override
//    public OverviewIndicatorsValueVO getOverviewInvestmentAnnual(ZZDIndicatorsQuery query) {
//        //组织Id
//        List<Org> orgs = new ArrayList<>();
//        String reportTime = query.getReportTime();
//        if (query.getOrgType() == 1){
//            //全大市
//            orgs = orgService.getAllOrg();
//        }else {
//            //监管企业
//            orgs = orgService.getGzwUnits(orgService.getDTFlag(reportTime));
//        }
//        switch (query.getColumnName()){
//            case "yearPlanInvestment":
//                return planInvestmentOverview(reportTime, orgs);
//            case "yearCompleteInvestment":
//                return completeInvestmentOverview(reportTime, orgs);
//            case "fixedAssetsInvestment":
//                return fixedAssetsInvestmentOverview(reportTime, orgs);
//            case "equityInvestment":
//                return equityInvestmentOverview(reportTime, orgs);
//            case "effectiveInvestmentCompletionRate":
//                return effectiveInvestmentCompletionRateOverview(reportTime, orgs);
//            case "keyProjectInvestmentCompletionRate":
//                return keyProjectInvestmentCompletionRateOverview(reportTime, orgs);
//            default:
//                return null;
//        }
//    }
//
//    /**
//     * @Description:  本年计划投资穿透
//     * @Author: Take-off
//     * @Date: 5:31 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO planInvestmentOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("本年计划投资").indicatorsValue(BigDecimal.ZERO).build();
//        //本年计划投资
//        String[] strList = reportTime.split(StringPool.DASH);
//        String year = strList[0];
//        List<BaseInvestmentPlan> planList = baseInvestmentPlanService.list(new LambdaQueryWrapper<BaseInvestmentPlan>().eq(BaseInvestmentPlan::getFilingYear, year)
//                .in(BaseInvestmentPlan::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//
//        if (CollectionUtil.isNotEmpty(planList)){
//            List<FixedInvestmentPlan> fixedInvestmentPlans = fixedInvestmentPlanService.list(new LambdaQueryWrapper<FixedInvestmentPlan>().in(FixedInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//            List<StakeInvestmentPlan> stakeInvestmentPlans = stakeInvestmentPlanService.list(new LambdaQueryWrapper<StakeInvestmentPlan>().in(StakeInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//            BigDecimal planInvestment = planList.stream().map(BaseInvestmentPlan::getPlannedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//            if (planInvestment.compareTo(BigDecimal.ZERO) <= 0) {
//                if (CollectionUtil.isNotEmpty(fixedInvestmentPlans)) {
//                    BigDecimal totalInvestment = fixedInvestmentPlans.stream().map(FixedInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//                if (CollectionUtil.isNotEmpty(stakeInvestmentPlans)) {
//                    BigDecimal totalInvestment = stakeInvestmentPlans.stream().map(StakeInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//            }
//            valueVO.setIndicatorsValue(planInvestment);
//            List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//            Map<String, List<BaseInvestmentPlan>> mapByOrg = planList.stream().filter(m -> Optional.ofNullable(m.getFilingUnitId()).isPresent()).collect(Collectors.groupingBy(BaseInvestmentPlan::getFilingUnitId));
//            for (String orgId:mapByOrg.keySet()){
//                List<BaseInvestmentPlan> baseInvestmentPlans = mapByOrg.get(orgId);
//                BigDecimal value = baseInvestmentPlans.stream().map(BaseInvestmentPlan::getPlannedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                if (value.compareTo(BigDecimal.ZERO) <= 0) {
//                    List<Long> planIds = baseInvestmentPlans.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList());
//                    if (CollectionUtil.isNotEmpty(fixedInvestmentPlans)) {
//                        BigDecimal totalInvestment = fixedInvestmentPlans.stream().filter(m -> planIds.contains(m.getBaseInvestmentPlanId())).map(FixedInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        value = value.add(totalInvestment);
//                    }
//                    if (CollectionUtil.isNotEmpty(stakeInvestmentPlans)) {
//                        BigDecimal totalInvestment = stakeInvestmentPlans.stream().filter(m -> planIds.contains(m.getBaseInvestmentPlanId())).map(StakeInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        value = value.add(totalInvestment);
//                    }
//                }
//                //获取单位
//                Optional<Org> first = orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst();
//                if (first.isPresent()){
//                    Org m = first.get();
//                    IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(m.getId()).unitName(m.getName()).value(value).orderNum(m.getOrderNum()).build();
//                    indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                }
//            }
//            valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//        }
//        return valueVO;
//    }
//
//    /**
//     * @Description:  已完成投资
//     * @Author: Take-off
//     * @Date: 5:39 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO completeInvestmentOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("已完成投资").indicatorsValue(BigDecimal.ZERO).build();
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, reportTime).in(BaseInvestmentExecution::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//        if (CollectionUtil.isNotEmpty(executions)) {
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)) {
//                //已经完成投资
//                BigDecimal completeInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                valueVO.setIndicatorsValue(completeInvestment);
//                List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//                Map<String, List<EffectiveInvestment>> mapByOrg = effectiveInvestments.stream().filter(m -> Optional.ofNullable(m.getCreateCompanyId()).isPresent()).collect(Collectors.groupingBy(EffectiveInvestment::getCreateCompanyId));
//
//                for (String orgId:mapByOrg.keySet()){
//                    BigDecimal value = mapByOrg.get(orgId).stream().map(EffectiveInvestment::getAllCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    //获取单位
//                    orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst().ifPresent(m -> {
//                        IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(m.getId()).unitName(m.getName()).value(value).orderNum(m.getOrderNum()).build();
//                        indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                    });
//                }
//                valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//            }
//        }
//        return valueVO;
//    }
//
//    /**
//     * @Description:  固定资产投资
//     * @Author: Take-off
//     * @Date: 5:39 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO fixedAssetsInvestmentOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("固定资产投资").indicatorsValue(BigDecimal.ZERO).build();
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, reportTime).in(BaseInvestmentExecution::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//        if (CollectionUtil.isNotEmpty(executions)) {
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)) {
//                //已经完成投资
//                BigDecimal completeInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteFixedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                valueVO.setIndicatorsValue(completeInvestment);
//                List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//                Map<String, List<EffectiveInvestment>> mapByOrg = effectiveInvestments.stream().filter(m -> Optional.ofNullable(m.getCreateCompanyId()).isPresent()).collect(Collectors.groupingBy(EffectiveInvestment::getCreateCompanyId));
//                for (String orgId:mapByOrg.keySet()){
//                    BigDecimal value = mapByOrg.get(orgId).stream().map(EffectiveInvestment::getAllCompleteFixedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    //获取单位
//                    orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst().ifPresent(m -> {
//                        IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(m.getId()).unitName(m.getName()).value(value).orderNum(m.getOrderNum()).build();
//                        indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                    });
//                }
//                valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//            }
//        }
//        return valueVO;
//    }
//
//    /**
//     * @Description:  股权投资
//     * @Author: Take-off
//     * @Date: 5:39 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO equityInvestmentOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("股权投资").indicatorsValue(BigDecimal.ZERO).build();
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, reportTime).in(BaseInvestmentExecution::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//        if (CollectionUtil.isNotEmpty(executions)) {
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)) {
//                //已经完成投资
//                BigDecimal completeInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteEquityInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                valueVO.setIndicatorsValue(completeInvestment);
//                List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//                Map<String, List<EffectiveInvestment>> mapByOrg = effectiveInvestments.stream().filter(m -> Optional.ofNullable(m.getCreateCompanyId()).isPresent()).collect(Collectors.groupingBy(EffectiveInvestment::getCreateCompanyId));
//                for (String orgId:mapByOrg.keySet()){
//                    BigDecimal value = mapByOrg.get(orgId).stream().map(EffectiveInvestment::getAllCompleteEquityInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    //获取单位
//                    orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst().ifPresent(m -> {
//                        IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(m.getId()).unitName(m.getName()).value(value).orderNum(m.getOrderNum()).build();
//                        indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                    });
//                }
//                valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//            }
//        }
//        return valueVO;
//    }
//
//    /**
//     * @Description:  有效投资完成率
//     * @Author: Take-off
//     * @Date: 5:39 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO effectiveInvestmentCompletionRateOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("有效投资完成率").indicatorsValue(BigDecimal.ZERO).build();
//
//        //本年计划投资
//        String[] strList = reportTime.split(StringPool.DASH);
//        String year = strList[0];
//        List<BaseInvestmentPlan> planList = baseInvestmentPlanService.list(new LambdaQueryWrapper<BaseInvestmentPlan>().eq(BaseInvestmentPlan::getFilingYear, year)
//                .in(BaseInvestmentPlan::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, reportTime).in(BaseInvestmentExecution::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//        if (CollectionUtil.isNotEmpty(planList)) {
//            Map<String, List<BaseInvestmentPlan>> planByOrg = planList.stream().filter(m -> Optional.ofNullable(m.getFilingUnitId()).isPresent()).collect(Collectors.groupingBy(BaseInvestmentPlan::getFilingUnitId));
//            List<FixedInvestmentPlan> fixedInvestmentPlans = fixedInvestmentPlanService.list(new LambdaQueryWrapper<FixedInvestmentPlan>().in(FixedInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//            List<StakeInvestmentPlan> stakeInvestmentPlans = stakeInvestmentPlanService.list(new LambdaQueryWrapper<StakeInvestmentPlan>().in(StakeInvestmentPlan::getBaseInvestmentPlanId, planList.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList())));
//            BigDecimal planInvestment = planList.stream().map(BaseInvestmentPlan::getPlannedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//            if (planInvestment.compareTo(BigDecimal.ZERO) <= 0) {
//                if (CollectionUtil.isNotEmpty(fixedInvestmentPlans)) {
//                    BigDecimal totalInvestment = fixedInvestmentPlans.stream().map(FixedInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//                if (CollectionUtil.isNotEmpty(stakeInvestmentPlans)) {
//                    BigDecimal totalInvestment = stakeInvestmentPlans.stream().map(StakeInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    planInvestment = planInvestment.add(totalInvestment);
//                }
//            }
//            if (CollectionUtil.isNotEmpty(executions)) {
//                //有效投资
//                List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                        executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//                if (CollectionUtil.isNotEmpty(effectiveInvestments)) {
//                    //有效投资完成率
//                    BigDecimal completeInvestment = effectiveInvestments.stream().map(EffectiveInvestment::getAllCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                    if (planInvestment.compareTo(BigDecimal.ZERO)>0){
//                        BigDecimal divide = completeInvestment.multiply(new BigDecimal("100")).divide(planInvestment, 2, RoundingMode.HALF_UP);
//                        valueVO.setIndicatorsValue(divide);
//                    }
//                    List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//                    Map<String, List<EffectiveInvestment>> mapByOrg = effectiveInvestments.stream().filter(m -> Optional.ofNullable(m.getCreateCompanyId()).isPresent()).collect(Collectors.groupingBy(EffectiveInvestment::getCreateCompanyId));
//                    for (String orgId:mapByOrg.keySet()){
//                        List<BaseInvestmentPlan> baseInvestmentPlans = planByOrg.get(orgId);
//                        BigDecimal investmentValue = baseInvestmentPlans.stream().map(BaseInvestmentPlan::getPlannedInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                       if (investmentValue.compareTo(BigDecimal.ZERO) <= 0) {
//                            List<Long> planIds = baseInvestmentPlans.stream().map(BaseInvestmentPlan::getId).collect(Collectors.toList());
//                            if (CollectionUtil.isNotEmpty(fixedInvestmentPlans)) {
//                                BigDecimal totalInvestment = fixedInvestmentPlans.stream().filter(m -> planIds.contains(m.getBaseInvestmentPlanId())).map(FixedInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                                investmentValue = investmentValue.add(totalInvestment);
//                            }
//                            if (CollectionUtil.isNotEmpty(stakeInvestmentPlans)) {
//                                BigDecimal totalInvestment = stakeInvestmentPlans.stream().filter(m -> planIds.contains(m.getBaseInvestmentPlanId())).map(StakeInvestmentPlan::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                                investmentValue = investmentValue.add(totalInvestment);
//                            }
//                        }
//
//                        BigDecimal value = mapByOrg.get(orgId).stream().map(EffectiveInvestment::getAllCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        //有效投资完成率
//                        BigDecimal divide = BigDecimal.ZERO;
//                        if (investmentValue.compareTo(BigDecimal.ZERO)>0){
//                             divide = value.multiply(new BigDecimal("100")).divide(investmentValue, 2, RoundingMode.HALF_UP);
//                        }
//                        //获取单位
//                        Optional<Org> first = orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst();
//                        if (first.isPresent()){
//                            Org org = first.get();
//                            IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(org.getId()).unitName(org.getName()).value(divide).orderNum(org.getOrderNum()).build();
//                            indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                        }
//                    }
//                    valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//                }
//            }
//        }
//        return valueVO;
//    }
//
//    /**
//     * @Description:  重点项目完成率
//     * @Author: Take-off
//     * @Date: 8:42 PM 2023/3/29
//     * @Param: [reportTime, orgs]
//     * @return: com.plian.system.vo.zzd.sys.OverviewIndicatorsValueVO
//     **/
//    private OverviewIndicatorsValueVO keyProjectInvestmentCompletionRateOverview(String reportTime, List<Org> orgs){
//        OverviewIndicatorsValueVO valueVO = OverviewIndicatorsValueVO.builder().indicatorsName("重点项目投资完成率").indicatorsValue(BigDecimal.ZERO).build();
//        //已完成投资
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>()
//                .eq(BaseInvestmentExecution::getFilingMonth, reportTime).in(BaseInvestmentExecution::getFilingUnitId, orgs.stream().map(Org::getId).collect(Collectors.toList())));
//        if (CollectionUtil.isNotEmpty(executions)) {
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)) {
//                //重点项目
//                List<ExecutionProjectSituation> projectSituations = executionProjectSituationService.list(new LambdaQueryWrapper<ExecutionProjectSituation>().in(ExecutionProjectSituation::getEffectiveInvestmentId,
//                        effectiveInvestments.stream().map(EffectiveInvestment::getId).collect(Collectors.toList())));
//                if (CollectionUtil.isNotEmpty(projectSituations)){
//                    List<ExecutionProjectSituation> mainProjects = projectSituations.stream().filter(m -> Optional.ofNullable(m.getIsMain()).isPresent() && m.getIsMain() == 2).collect(Collectors.toList());
//                    if (CollectionUtil.isNotEmpty(mainProjects)){
//                        //全年计划和
//                        BigDecimal planTotalInvestment = mainProjects.stream().map(ExecutionProjectSituation::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        //至上月底完成
//                        BigDecimal lastCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getLastCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        //本月完成投资
//                        BigDecimal thisCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        if (planTotalInvestment.compareTo(BigDecimal.ZERO)>0){
//                            BigDecimal divide = (lastCompleteInvestment.add(thisCompleteInvestment)).multiply(new BigDecimal("100")).divide(planTotalInvestment, 2, RoundingMode.HALF_UP);
//                            valueVO.setIndicatorsValue(divide);
//                        }
//                        List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//                        Map<String, List<ExecutionProjectSituation>> mapByOrg = mainProjects.stream().filter(m -> Optional.ofNullable(m.getCreateCompanyId()).isPresent()).collect(Collectors.groupingBy(ExecutionProjectSituation::getCreateCompanyId));
//                        for (String orgId:mapByOrg.keySet()){
//                            BigDecimal divide = BigDecimal.ZERO;
//                            List<ExecutionProjectSituation> projectSituationList = mapByOrg.get(orgId);
//                            //全年计划和
//                            BigDecimal totalInvestment = projectSituationList.stream().map(ExecutionProjectSituation::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                            //至上月底完成
//                            BigDecimal lastInvestment = projectSituationList.stream().map(ExecutionProjectSituation::getLastCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                            //本月完成投资
//                            BigDecimal thisInvestment = projectSituationList.stream().map(ExecutionProjectSituation::getCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                            if (totalInvestment.compareTo(BigDecimal.ZERO)>0){
//                                 divide = (lastInvestment.add(thisInvestment)).multiply(new BigDecimal("100")).divide(totalInvestment, 2, RoundingMode.HALF_UP);
//                            }
//                            //获取单位
//                            Optional<Org> first = orgs.stream().filter(m -> m.getId().equals(orgId)).findFirst();
//                            if (first.isPresent()){
//                                Org org = first.get();
//                                IndicatorsUnitDetailVO indicatorsUnitDetailVO = IndicatorsUnitDetailVO.builder().unitId(org.getId()).unitName(org.getName()).value(divide).orderNum(org.getOrderNum()).build();
//                                indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                            }
//
//                        }
//                        valueVO.setUnitDetailList(indicatorsUnitDetailVOS);
//                    }
//                }
//            }
//        }
//        return valueVO;
//    }
//
//
//    @Override
//    public ProjectNatureVO getProjectNature(String date){
//        ProjectNatureVO projectNatureVO = new ProjectNatureVO();
//        List<ProjectInfo> projectInfos = projectInfoService.list(new LambdaQueryWrapper<ProjectInfo>()
//                .le(ProjectInfo::getUpdateTime,DateUtil.plusMonths(DateUtil.parse(date,DateUtil.PATTERN_MONTH),1)));
//        if (CollectionUtil.isNotEmpty(projectInfos)){
//            List<FixedInvestmentPlan> fixedInvestmentPlans = fixedInvestmentPlanService.list(new LambdaQueryWrapper<FixedInvestmentPlan>().in(FixedInvestmentPlan::getProjectId, projectInfos.stream().map(ProjectInfo::getId).collect(Collectors.toList())));
//            List<StakeInvestmentPlan> stakeInvestmentPlans = stakeInvestmentPlanService.list(new LambdaQueryWrapper<StakeInvestmentPlan>().in(StakeInvestmentPlan::getProjectId, projectInfos.stream().map(ProjectInfo::getId).collect(Collectors.toList())));
//
//            //交通设施
//            List<ProjectInfo> transportation = projectInfos.stream().filter(m -> Optional.ofNullable(m.getProjectNatureId()).isPresent() && "166003".equals(m.getProjectNatureId()) )
//                    .collect(Collectors.toList());
//            projectNatureVO.setTrafficFacilities(getPlanInvestment(transportation,fixedInvestmentPlans,stakeInvestmentPlans));
//            //公共服务
//            List<ProjectInfo>  publicService = projectInfos.stream().filter(m -> Optional.ofNullable(m.getProjectNatureId()).isPresent() && "166005".equals(m.getProjectNatureId()))
//                    .collect(Collectors.toList());
//            projectNatureVO.setPublicService(getPlanInvestment(publicService,fixedInvestmentPlans,stakeInvestmentPlans));
//            //现代产业
//            List<ProjectInfo>  modernIndustry = projectInfos.stream().filter(m -> Optional.ofNullable(m.getProjectNatureId()).isPresent() && "166002".equals(m.getProjectNatureId()) )
//                    .collect(Collectors.toList());
//            projectNatureVO.setModernIndustry(getPlanInvestment(modernIndustry,fixedInvestmentPlans,stakeInvestmentPlans));
//            //生态环保
//            List<ProjectInfo>  ecologicalEnvironment = projectInfos.stream().filter(m -> Optional.ofNullable(m.getProjectNatureId()).isPresent() && "166004".equals(m.getProjectNatureId()) )
//                    .collect(Collectors.toList());
//            projectNatureVO.setEcologicalEnvironment(getPlanInvestment(ecologicalEnvironment,fixedInvestmentPlans,stakeInvestmentPlans));
//            //科技创新
//            List<ProjectInfo>  scienceAndTechnology = projectInfos.stream().filter(m -> Optional.ofNullable(m.getProjectNatureId()).isPresent() && "166001".equals(m.getProjectNatureId()) )
//                    .collect(Collectors.toList());
//            projectNatureVO.setScienceAndTechnology(getPlanInvestment(scienceAndTechnology,fixedInvestmentPlans,stakeInvestmentPlans));
//
//        }
//        return projectNatureVO;
//    }
//
//    /**
//     * @Description: //TODO 计算投资总额
//     * @Author: Take-off
//     * @Date: 11:15 AM 2023/4/4
//     * @Param: [transportation, fixedInvestmentPlans, stakeInvestmentPlans]
//     * @return: java.math.BigDecimal
//     **/
//    private BigDecimal getPlanInvestment(List<ProjectInfo> transportation,List<FixedInvestmentPlan> fixedInvestmentPlans,List<StakeInvestmentPlan> stakeInvestmentPlans){
//        BigDecimal planInvestment = BigDecimal.ZERO;
//        if (CollectionUtil.isNotEmpty(transportation)){
//            for (ProjectInfo projectInfo:transportation){
//                Optional<FixedInvestmentPlan> max = fixedInvestmentPlans.stream().filter(m -> Optional.ofNullable(m.getProjectId()).isPresent() && m.getProjectId().equals(projectInfo.getId())).max(Comparator.comparing(FixedInvestmentPlan::getUpdateTime));
//                if (max.isPresent()){
//                    BigDecimal planInvestmentTotal = max.get().getPlanInvestmentTotal();
//                    if (Optional.ofNullable(planInvestmentTotal).isPresent()){
//                        planInvestment = planInvestment.add(planInvestmentTotal);
//                    }
//                }
//
//                Optional<StakeInvestmentPlan> stake = stakeInvestmentPlans.stream().filter(m -> Optional.ofNullable(m.getProjectId()).isPresent() && m.getProjectId().equals(projectInfo.getId())).max(Comparator.comparing(StakeInvestmentPlan::getUpdateTime));
//                if (max.isPresent()){
//                    BigDecimal planInvestmentTotal = max.get().getPlanInvestmentTotal();
//                    if (Optional.ofNullable(planInvestmentTotal).isPresent()){
//                        planInvestment = planInvestment.add(planInvestmentTotal);
//                    }
//                }
//            }
//        }
//        return planInvestment.divide(new BigDecimal("10000"),2,RoundingMode.HALF_UP);
//    }
//
//    @Override
//    public List<IndicatorsUnitDetailVO> investmentFinish(Integer type, String date){
//        return getInvestmentValueList(type,date,1).getIndicatorsUnitDetailVOS();
//    }
//
//    @Override
//    public List<IndicatorsUnitDetailVO> equityInvestmentFinish(Integer type, String date){
//        return getInvestmentValueList(type,date,2).getIndicatorsUnitDetailVOS();
//    }
//
//    @Override
//    public InvestmentFinishVO fixedInvestmentFinish(Integer type,String date){
//        return getInvestmentValueList(type,date,3);
//    }
//
//    @Override
//    public InvestmentFinishVO mainInvestmentFinish(Integer type,String date){
//        return getInvestmentValueList(type,date,4);
//    }
//
//    /**
//     * @Description: //TODO 获取投资完成情况列表
//     * @Author: Take-off
//     * @Date: 11:55 PM 2023/3/15
//     * @Param: [type, date, dataType]
//     * @return: java.util.List<com.plian.system.vo.zzd.finance.IndicatorsUnitDetail>
//     **/
//    private InvestmentFinishVO getInvestmentValueList(Integer type, String date, Integer dataType){
//        InvestmentFinishVO investmentFinishVO = new InvestmentFinishVO();
//
//        List<IndicatorsUnitDetailVO> indicatorsUnitDetailVOS = new ArrayList<>();
//
////        List<Org> units = orgService.directlyUnderUnitNoChild(false).getList();
//
//        List<Enterprise> enterpriseList = new ArrayList<>();
//        try {
//            enterpriseList  =  enterpriseService.getAllUnitCheckName();
//        }catch (Exception e){
//            log.error(ExceptionUtils.getFullStackTrace(e));
//        }
//        Map<String, String> unitCheckMap = new HashMap<>();
//        if (CollectionUtil.isNotEmpty(enterpriseList)){
//            unitCheckMap = enterpriseList.stream().collect(Collectors
//                    .toMap(Enterprise::getOrgId, Enterprise::getUnitCheck));
//        }
//        //本月投资执行
//        List<BaseInvestmentExecution> executions = baseInvestmentExecutionService.list(new LambdaQueryWrapper<BaseInvestmentExecution>().eq(BaseInvestmentExecution::getFilingMonth, date)
//                    .eq(BaseInvestmentExecution::getStatus, FormStatusConstant.FINISH));
//        if (CollectionUtil.isNotEmpty(executions)) {
//            //有效投资
//            List<EffectiveInvestment> effectiveInvestments = effectiveInvestmentService.list(new LambdaQueryWrapper<EffectiveInvestment>().in(EffectiveInvestment::getBaseInvestmentExecutionId,
//                    executions.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList())));
//
//            //完成率
//            List<ExecutionProjectSituation> projectSituations = new ArrayList<>();
//            if (CollectionUtil.isNotEmpty(effectiveInvestments)){
//                projectSituations = executionProjectSituationService.list(new LambdaQueryWrapper<ExecutionProjectSituation>().in(ExecutionProjectSituation::getEffectiveInvestmentId,
//                        effectiveInvestments.stream().map(EffectiveInvestment::getId).collect(Collectors.toList())));
//            }
//            //累计完成投资
//            BigDecimal completeInvestment = BigDecimal.ZERO;
//            //计划投资
//            BigDecimal planInvestment = BigDecimal.ZERO;
//            //项目数量
//            BigDecimal projectTotals = BigDecimal.ZERO;
//            Set<String> orgIds = executions.stream().map(BaseInvestmentExecution::getFilingUnitId).filter(m -> Optional.ofNullable(m).isPresent()).collect(Collectors.toSet());
//            for (String orgId:orgIds){
//                IndicatorsUnitDetailVO indicatorsUnitDetailVO = new IndicatorsUnitDetailVO();
//                indicatorsUnitDetailVO.setUnitId(orgId);
//
//                if (CollectionUtil.isNotEmpty(unitCheckMap) && unitCheckMap.containsKey(orgId)){
//                    indicatorsUnitDetailVO.setUnitName(unitCheckMap.get(orgId));
//                }else {
//                    indicatorsUnitDetailVO.setUnitName(orgService.getById(orgId).getName());
//                }
//
//                BigDecimal sumValue = BigDecimal.ZERO;
//                //完成率
//                BigDecimal completeRatio = BigDecimal.ZERO;
//                List<BaseInvestmentExecution> executionList = executions.stream().filter(m -> Optional.ofNullable(m.getFilingUnitId()).isPresent() && orgId.equals(m.getFilingUnitId())).collect(Collectors.toList());
//                if (CollectionUtil.isNotEmpty(executionList)){
//                    List<EffectiveInvestment> effectiveInvestmentList = effectiveInvestments.stream().filter(m -> executionList.stream().map(BaseInvestmentExecution::getId).collect(Collectors.toList()).contains(m.getBaseInvestmentExecutionId())).collect(Collectors.toList());
//                    if (CollectionUtil.isNotEmpty(effectiveInvestmentList)){
//                        switch (dataType){
//                            case 1: sumValue = effectiveInvestmentList.stream().map(EffectiveInvestment::getAllCompleteInvestment).reduce(BigDecimal.ZERO, BigDecimal::add);completeInvestment = completeInvestment.add(sumValue);break;
//                            case 2: sumValue = effectiveInvestmentList.stream().map(EffectiveInvestment::getAllCompleteEquityInvestment).reduce(BigDecimal.ZERO, BigDecimal::add);completeInvestment = completeInvestment.add(sumValue);break;
//                            case 3: sumValue = effectiveInvestmentList.stream().map(EffectiveInvestment::getAllCompleteFixedInvestment).reduce(BigDecimal.ZERO, BigDecimal::add);completeInvestment = completeInvestment.add(sumValue);break;
//                            default:break;
//                        }
//                        if (CollectionUtil.isNotEmpty(projectSituations)){
//                            List<ExecutionProjectSituation> projectSituationList = projectSituations.stream().filter(m -> effectiveInvestmentList.stream().map(EffectiveInvestment::getId).collect(Collectors.toList()).contains(m.getEffectiveInvestmentId())).collect(Collectors.toList());
//                            if (CollectionUtil.isNotEmpty(projectSituationList)){
//                                //根据组织/数据类型筛选
//                                switch (dataType){
//                                    case 1: projectSituationList = projectSituationList;break;
//                                    case 2: projectSituationList = projectSituationList.stream().filter(m -> m.getProjectType() == 1 ).collect(Collectors.toList());break;
//                                    case 3: projectSituationList = projectSituationList.stream().filter(m -> m.getProjectType() == 2).collect(Collectors.toList());break;
//                                    case 4: projectSituationList = projectSituationList.stream().filter(m -> Optional.ofNullable(m.getIsMain()).isPresent() && m.getIsMain() == 2).collect(Collectors.toList());
//                                    sumValue = addPlanTotalInvestment(projectSituationList);completeInvestment = completeInvestment.add(sumValue);break;
//                                    default:break;
//                                }
//                                if (CollectionUtil.isNotEmpty(projectSituationList)){
//                                    projectTotals = new BigDecimal(projectSituationList.size());
//                                    BigDecimal planTotal = projectSituationList.stream().map(ExecutionProjectSituation::getPlanTotalInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                                    indicatorsUnitDetailVO.setPlanTotal(planTotal);
//                                    planInvestment = planInvestment.add(planTotal);
//                                    if (planTotal.compareTo(BigDecimal.ZERO) >0){
//                                        completeRatio = sumValue.multiply(new BigDecimal("100")).divide(planTotal,2,RoundingMode.HALF_UP);
//                                    }
//                                }
//                            }
//                        }
//                    }
//                }
//                indicatorsUnitDetailVO.setSumValue(sumValue);
//                if (type == 1){
//                    //投资金额
//                    indicatorsUnitDetailVO.setValue(sumValue.divide(new BigDecimal(10000),4,RoundingMode.HALF_UP));
//                }else if (type == 2){
//                    //完成率
//                    indicatorsUnitDetailVO.setValue(completeRatio);
//                }else if (type == 3){
//                    //参与项目
//                    indicatorsUnitDetailVO.setValue(projectTotals);
//                }
//                indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//            }
//            List<GraphicOrgRelation> orgRelations = graphicOrgRelationService.list(new LambdaQueryWrapper<GraphicOrgRelation>().eq(GraphicOrgRelation::getType, 2).ne(GraphicOrgRelation::getParentId, "p4"));
//            Map<String, List<GraphicOrgRelation>> mapByGraph = orgRelations.stream().collect(Collectors.groupingBy(GraphicOrgRelation::getParentName));
//            for (String parentName:mapByGraph.keySet()){
//                IndicatorsUnitDetailVO indicatorsUnitDetailVO = new IndicatorsUnitDetailVO();
//                indicatorsUnitDetailVO.setUnitName(parentName);
//                List<String> childIds = mapByGraph.get(parentName).stream().map(GraphicOrgRelation::getChildId).collect(Collectors.toList());
//                List<IndicatorsUnitDetailVO> detailVOS = indicatorsUnitDetailVOS.stream().filter(m -> Optional.ofNullable(m.getUnitId()).isPresent() && childIds.contains(m.getUnitId())).collect(Collectors.toList());
//                if (CollectionUtil.isNotEmpty(detailVOS)){
//                    if (type == 2){
//                        //投资完成率
//                        BigDecimal sumValue = detailVOS.stream().map(IndicatorsUnitDetailVO::getSumValue).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        BigDecimal planTotal = detailVOS.stream().map(IndicatorsUnitDetailVO::getPlanTotal).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//                        if (planTotal.compareTo(BigDecimal.ZERO) >0){
//                            indicatorsUnitDetailVO.setValue(sumValue.multiply(new BigDecimal("100")).divide(planTotal,2,RoundingMode.HALF_UP));
//                        }else {
//                            indicatorsUnitDetailVO.setValue(BigDecimal.ZERO);
//                        }
//                    }else {
//                        indicatorsUnitDetailVO.setValue(detailVOS.stream().map(IndicatorsUnitDetailVO::getValue).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add));
//                    }
//                    indicatorsUnitDetailVOS.add(indicatorsUnitDetailVO);
//                }
//            }
//            List<IndicatorsUnitDetailVO> childDetails = indicatorsUnitDetailVOS.stream().filter(m -> Optional.ofNullable(m.getUnitId()).isPresent() && orgRelations.stream().map(GraphicOrgRelation::getChildId).collect(Collectors.toList()).contains(m.getUnitId())).collect(Collectors.toList());
//            indicatorsUnitDetailVOS.removeAll(childDetails);
//            indicatorsUnitDetailVOS = indicatorsUnitDetailVOS.stream().sorted(Comparator.comparing(IndicatorsUnitDetailVO::getValue).reversed()).collect(Collectors.toList());
//            investmentFinishVO.setIndicatorsUnitDetailVOS(indicatorsUnitDetailVOS);
//            investmentFinishVO.setCompleteInvestment(completeInvestment.divide(new BigDecimal(10000),4,RoundingMode.HALF_UP));
//            investmentFinishVO.setProjectTotals(projectTotals.intValue());
//            if (planInvestment.compareTo(BigDecimal.ZERO) >0){
//                BigDecimal divide = completeInvestment.multiply(new BigDecimal("100")).divide(planInvestment, 2, RoundingMode.HALF_UP);
//                investmentFinishVO.setCompleteRatio(divide);
//            }else {
//                investmentFinishVO.setCompleteRatio(BigDecimal.ZERO);
//            }
//        }
//        return investmentFinishVO;
//    }
//
//    /**
//     * @Description: //TODO 投资计划详情，相加
//     * @Author: Take-off
//     * @Date: 12:25 AM 2023/3/16
//     * @Param: [mainProjects]
//     * @return: java.math.BigDecimal
//     **/
//    private BigDecimal addPlanTotalInvestment(List<ExecutionProjectSituation> mainProjects){
//       //至上月底完成
//        BigDecimal lastCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getLastCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//        //本月完成投资
//        BigDecimal thisCompleteInvestment = mainProjects.stream().map(ExecutionProjectSituation::getCompleteInvestment).filter(m -> Optional.ofNullable(m).isPresent()).reduce(BigDecimal.ZERO, BigDecimal::add);
//        return lastCompleteInvestment.add(thisCompleteInvestment);
//    }
//
//}
